#!/usr/bin/python
# Filename: main.mi2app

import os
import sys
import shutil
import traceback

import mi2app_utils
from mobile_insight.monitor import OnlineMonitor, OfflineReplayer
from mobile_insight.analyzer import WcdmaRrcAnalyzer

try:
    cache_directory  = mi2app_utils.get_cache_dir()
    log_directory    = os.path.join(cache_directory, "mi2log")
    mi_directory = mi2app_utils.get_mobileinsight_path()

    # src = OnlineMonitor()
    # src.set_skip_decoding(False)
    # src.set_log_directory(log_directory)
    # src.set_log_cut_size(1000.0)

    src = OfflineReplayer()
    src.set_input_path(os.path.join(mi_directory,"demo/RRCStateMachine/WCDMA_RRC_state_sample.mi2log"))

    wcdma_rrc_analyzer = WcdmaRrcAnalyzer()
    wcdma_rrc_analyzer.set_source(src)

    src.run()

except:
    # src.log_error(traceback.format_exc())
    print traceback.format_exc()

# finally:
    # mi2app_utils.detach_thread()
    pass